/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.base.enums;

/**
 * 数据状态枚举
 * 
 * @author Wien(luweien@aliyun.com)
 *
 */
public enum StatusEnum {

	/** 正常状态：0 或 null */
	NORMAL(0, "正常"),

	/** 隐藏状态：1 */
	HIDDEN(1, "隐藏");

	private final int code;

	private final String message;

	private StatusEnum(int code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @return Return the integer value of this status code.
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @return Return the reason phrase of this code.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Return the enum constant of this type with the specified numeric value.
	 * @param code
	 * @return
	 */
	public static StatusEnum valueOf(int code) {
		for (StatusEnum stateEnum : values()) {
			if (stateEnum.getCode() == code) {
				return stateEnum;
			}
		}
		throw new IllegalArgumentException("No matching constant for [" + code + "]");
	}

}